/**
 * 初始化资质认证详情对话框
 */
var AuthInfoDlg = {
    authInfoData : {}
};

/**
 * 清除数据
 */
AuthInfoDlg.clearData = function() {
    this.authInfoData = {};
}

/**
 * 设置对话框中的数据
 *
 * @param key 数据的名称
 * @param val 数据的具体值
 */
AuthInfoDlg.set = function(key, val) {
    this.authInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
    return this;
}

/**
 * 设置对话框中的数据
 *
 * @param key 数据的名称
 * @param val 数据的具体值
 */
AuthInfoDlg.get = function(key) {
    return $("#" + key).val();
}

/**
 * 关闭此对话框
 */
AuthInfoDlg.close = function() {
    parent.layer.close(window.parent.Auth.layerIndex);
}

/**
 * 收集数据
 */
AuthInfoDlg.collectData = function() {
    this
    .set('authenticationId')
    .set('userId')
    .set('organName')
    .set('organType')
    .set('mappingGrade')
    .set('mappingNo')
    .set('organNo')
    .set('applyType')
    .set('legalPersonName')
    .set('legalPersonPhone')
    .set('province')
    .set('city')
    .set('area')
    .set('address')
    .set('mappingImage')
    .set('organImage')
    .set('legalFrontImage')
    .set('legalBackImage')
    .set('operatorFrontImage')
    .set('operatorBackImage')
    .set('ndaImage')
    .set('empowerImage')
    .set('linkName')
    .set('linkPhone')
    .set('linkEmail')
    .set('linkQq')
    .set('linkWechat')
    .set('authState')
    .set('createTime')
    .set('updateTime')
    .set('flag');
}

/**
 * 提交添加
 */
AuthInfoDlg.addSubmit = function() {

    this.clearData();
    this.collectData();

    //提交信息
    var ajax = new $ax(Feng.ctxPath + "/auth/add", function(data){
        Feng.success("添加成功!");
        window.parent.Auth.table.refresh();
        AuthInfoDlg.close();
    },function(data){
        Feng.error("添加失败!" + data.responseJSON.message + "!");
    });
    ajax.set(this.authInfoData);
    ajax.start();
}

/**
 * 提交修改
 */
AuthInfoDlg.editSubmit = function() {

    this.clearData();
    this.collectData();

    //提交信息
    var ajax = new $ax(Feng.ctxPath + "/auth/update", function(data){
        Feng.success("修改成功!");
        window.parent.Auth.table.refresh();
        AuthInfoDlg.close();
    },function(data){
        Feng.error("修改失败!" + data.responseJSON.message + "!");
    });
    ajax.set(this.authInfoData);
    ajax.start();
}

$(function() {

});
